package cn.walls1717.ggkt.vod.controller;

import cn.walls1717.ggkt.result.Result;
import cn.walls1717.ggkt.vod.service.FileUploadService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * COS文件上传相关接口
 * <p>
 * 使用腾讯云COS实现静态资源的存储
 * 项目中的图片资源都存储在COS
 *
 * @author walls1717
 * @since 2022/7/14
 **/
@Api(tags = "文件上传相关接口")
@RestController
@RequestMapping("/admin/vod/file")
public class FileUploadController {

    @Autowired
    private FileUploadService fileUploadService;

    @ApiOperation("文件上传")
    @PostMapping("upload")
    public Result<String> upload(@RequestParam("file") MultipartFile file) {
        String uploadUrl = fileUploadService.upload(file);
        return Result.success(uploadUrl).message("文件上传成功");
    }

}
